package com.shoujifeng.snowmusic.player;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.shoujifeng.snowmusic.player.R;
import com.shoujifeng.snowmusic.db.DatabaseUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

/**
 * 本地专辑列表
 * @author luo
 *
 */
public class NativeSpecialActivity extends Activity{
	private ListView listView;
	private ListAdapter mAdapter;
	private View lineLay;
	private List<HashMap<String, String>> list;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.native_special);
		init();
	}
	public void init() {
		listView = (ListView) findViewById(R.id.native_special_list);
		listView.setDivider(null);
		lineLay = LayoutInflater.from(NativeSpecialActivity.this).inflate(R.layout.line_layout, null);
		listView.addFooterView(lineLay);
		listView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				// TODO Auto-generated method stub
				TextView specialName = (TextView) view
						.findViewById(R.id.spceialName);
				Intent intent = new Intent(NativeSpecialActivity.this,
						MusicBySpecialActivity.class);
				intent.putExtra("spceialName", specialName.getText()
						.toString());
				startActivity(intent);
				overridePendingTransition(R.anim.right_in, R.anim.left_out);
			}
		});
		setListView();
	}

	private void setListView() {
		list = new ArrayList<HashMap<String, String>>();
		DatabaseUtil databaseUtil = new DatabaseUtil(NativeSpecialActivity.this);
		list = new ArrayList<HashMap<String, String>>();
		list =databaseUtil.queryAlbumName();
		mAdapter = new SimpleAdapter(this, list, R.layout.native_special_list,
				new String[] {"spceialName", "playerName" }, new int[] {R.id.spceialName, R.id.playerName });
		listView.setAdapter(mAdapter);
	}
	
}
